/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package boundaries;

import business.UserManager;
import entity.Event;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;

import javax.inject.Named;

/**
 *
 * @author Alessandro
 */
@ManagedBean
@SessionScoped
public class UserBean implements Serializable{
    
    @EJB
    UserManager um;
    
    private List<Event> calendar;
    
    private String searchText;
    
    public UserBean(){
        
    }
    
    public String getName(){
        return um.getLoggedUser().getFirstName()+" "+ um.getLoggedUser().getLastName();
    }
    
    public String getVisibility(){
        System.out.println("ciao sono userBean, col get visibility");
        return um.getLoggedUser().getVisibility().toString();
    }
    
    public String changeVisibility(){
        System.out.println("ciao, sono userbean, ora chiamo changevisib di usermanager");
        
        return um.changeVisibility();
    }

    public String getSearchText() {
        return searchText;
    }

    public void setSearchText(String searchText) {
        this.searchText = searchText;
    }

    public List<Event> getCalendar() {
        return calendar;
    }

    public void setCalendar(List<Event> myEvents) {
        this.calendar = myEvents;
    }
    
    
    
    public String loadCalendar(){
       return "myEvents";
    }



    
    
    public String search() {
        return "searching?faces-redirect=true&text="+searchText;
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
}
